﻿/*
 * ********************************************************************************************************************
 *
 *               iFHS7.
 *              ;BBMBMBMc                  rZMBMBR              BMB
 *              MBEr:;PBM,               7MBMMEOBB:             BBB                       RBW
 *     XK:      BO     SB.     :SZ       MBM.       c;;     ir  BBM :FFr       :SSF:    ;xBMB:r   iuGXv.    i:. iF2;
 *     DBBM0r.  :D     S7   ;XMBMB       GMBMu.     MBM:   BMB  MBMBBBMBMS   WMBMBMBBK  MBMBMBM  BMBRBMBW  .MBMBMBMBB
 *      :JMRMMD  ..    ,  1MMRM1;         ;MBMBBR:   MBM  ;MB:  BMB:   MBM. RMBr   sBMH   BM0         UMB,  BMB.  KMBv
 *     ;.   XOW  B1; :uM: 1RE,   i           .2BMBs  rMB. MBO   MBO    JMB; MBB     MBM   BBS    7MBMBOBM:  MBW   :BMc
 *     OBRJ.SEE  MRDOWOR, 3DE:7OBM       .     ;BMB   RMR7BM    BMB    MBB. BMB    ,BMR  .BBZ   MMB   rMB,  BMM   rMB7
 *     :FBRO0D0  RKXSXPR. JOKOOMPi       BMBSSWBMB;    BMBB:    MBMB0ZMBMS  .BMBOXRBMB    MBMDE RBM2;SMBM;  MBB   xBM2
 *         iZGE  O0SHSPO. uGZ7.          sBMBMBDL      :BMO     OZu:BMBK,     rRBMB0;     ,EBMB  xBMBr:ER.  RDU   :OO;
 *     ,BZ, 1D0  RPSFHXR. xWZ .SMr                  . .BBB
 *      :0BMRDG  RESSSKR. 2WOMBW;                   BMBMR
 *         i0BM: SWKHKGO  MBDv
 *           .UB  OOGDM. MK,                                          Copyright (c) 2015-2019.  斯伯坦机器人
 *              ,  XMW  ..
 *                  r                                                                     All rights reserved.
 *
 * ********************************************************************************************************************
 */

using MongoDB.Driver;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;

namespace MongoPI
{
    /// <summary>
    /// UserManageView.xaml 的交互逻辑
    /// </summary>
    public partial class UserManageView : UserControl, INotifyPropertyChanged
    {
        /// <summary>
        /// 实现INotifyPropertyChanged接口
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;
        /// <summary>
        /// Mongo数据库
        /// </summary>
        private IMongoDatabase mDatabase;

        /// <summary>
        /// 用户管理视图构造函数
        /// </summary>
        public UserManageView(string server, IMongoDatabase database)
        {
            InitializeComponent();
            DataContext = this;

            mDatabase = database;
            return;
        } // Function UserManageView()

        #region UI命令
        /// <summary>
        /// 添加用户命令
        /// </summary>
        /// <param name="sender">事件的发送者</param>
        /// <param name="e">事件参数</param>
        private void CmdUserAdd_Executed(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
        {
            var dlg = new UserDialog(mDatabase);
            dlg.ShowDialog();
            return;
        } // Function CmdUserAdd_Executed()

        /// <summary>
        /// 删除用户命令
        /// </summary>
        /// <param name="sender">事件的发送者</param>
        /// <param name="e">事件参数</param>
        private void CmdUserDrop_Executed(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
        {

        } // Function CmdUserDrop_Executed()

        /// <summary>
        /// 编辑用户命令
        /// </summary>
        /// <param name="sender">事件的发送者</param>
        /// <param name="e">事件参数</param>
        private void CmdUserEdit_Executed(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
        {
            var dlg = new UserDialog(mDatabase);
            dlg.ShowDialog();
            return;
        } // Function CmdUserEdit_Executed()

        /// <summary>
        /// 是可可以执行编辑用户命令
        /// </summary>
        /// <param name="sender">事件的发送者</param>
        /// <param name="e">事件参数</param>
        private void CmdUserEdit_CanExecute(object sender, System.Windows.Input.CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = true;
            return;
        } // Function CmdUserEdit_CanExecute()

        /// <summary>
        /// 授予用户权限命令
        /// </summary>
        /// <param name="sender">事件的发送者</param>
        /// <param name="e">事件参数</param>
        private void CmdUserGrant_Executed(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
        {
            // TODO:
            MessageBox.Show("CmdUserGrant_Executed");
            return;
        } // Function CmdUserGrant_Executed()

        /// <summary>
        /// 取消用户权限命令
        /// </summary>
        /// <param name="sender">事件的发送者</param>
        /// <param name="e">事件参数</param>
        private void CmdUserRevoke_Executed(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
        {
            // TODO:
            MessageBox.Show("CmdUserRevoke_Executed");
            return;
        } // Function CmdUserRevoke_Executed()

        /// <summary>
        /// 是否可以执行取消用户权限命令
        /// </summary>
        /// <param name="sender">事件的发送者</param>
        /// <param name="e">事件参数</param>
        private void CmdUserRevoke_CanExecute(object sender, System.Windows.Input.CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = true;
            return;
        } // Function CmdUserRevoke_CanExecute()

        /// <summary>
        /// 刷新命令
        /// </summary>
        /// <param name="sender">事件的发送者</param>
        /// <param name="e">事件参数</param>
        private void ButtonRefresh_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            MessageBox.Show("ButtonRefresh_Click");
            return;
        } // Function ButtonRefresh_Click()

        #endregion
    } // Class UserManageView()
} // Namespace MongoPI
